package com.codemes.happylist.utils;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;

import java.io.InputStream;

/**
 * @author nscoffee
 */
@Slf4j
public class HttpClientUtil {

    public static HttpResponse get(String url){
        HttpRequest request = HttpUtil.createGet(url);
        HttpHeaderUtil.setRequestHeader(request);
        log.info("headers = {}",request.headers());
        return request.execute();
    }

    public static InputStream getInput(String url){
        HttpRequest request = HttpUtil.createGet(url);
        HttpHeaderUtil.setRequestSecHeader(request);
        log.info("headers = {}",request.headers());
        return request.execute().bodyStream();
    }
}
